﻿using System;
using System.Windows;

namespace MediaAssistant.Controls.SplashScreen
{
    /// <summary>
    /// Helper to show or close given splash window
    /// </summary>
    public static class Splasher
    {
        /// <summary>
        /// 
        /// </summary>
        private static Window mSplash;
        /// <summary>
        /// Get or set the splash screen window
        /// </summary>
        public static Window Splash
        {
            get
            {
                return mSplash;
            }
            set
            {
                mSplash = value;
            }
        }
        
        public static void Show ( )
        {
            if (Splash == null)
                Splash = new SplashScreen();
            if ( mSplash != null )
            {
                mSplash.Show ( );
            }
        }

        /// <summary>
        /// Close splash screen
        /// </summary>
        public static void Close ( )
        {
            if ( mSplash != null )
            {
                mSplash.Close ( );

                if ( mSplash is IDisposable )
                    ( mSplash as IDisposable ).Dispose ( );
                mSplash = null;
            }
        }

        public static void SetMessage(string message)
        {
            MessageListener.Instance.ReceiveMessage(message);
        }

        public static void ShowBusy(bool show)
        {
            MessageListener.Instance.BusyIconVisibility = show ? Visibility.Visible : Visibility.Hidden;
        }

    }
}